package com.ecar.api.service.common.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.ecar.api.service.common.ModelSetService;
import com.ecar.api.support.util.UuidUtils;
import com.ecar.core.driver.dao.ModelSetMapper;
import com.ecar.core.driver.entity.ModelSet;

@Service
@Transactional
public class ModelSetServiceImpl implements ModelSetService{
	
	@Autowired
	ModelSetMapper modelSetMapper;
	
	/**
	 * 获取接单模型
	 * 
	 * @author fire
	 */
	@Override
	public ModelSet selectByDriverId(String driverId) {
		return modelSetMapper.selectByDriverId(driverId);
	}
	
	
	/**
	 * 接单模型设定
	 */
	@Override
	public boolean InsertModelSet(ModelSet record) {
		boolean flag=false;
		ModelSet rm=modelSetMapper.selectByDriverId(record.getDriverId());
		if(rm==null){
			record.setId(UuidUtils.getUUID());
			int i=modelSetMapper.insert(record);
			if(i>0){
				flag=true;
			}
		}else{
			int i=modelSetMapper.updateByDriverId(record);
			if(i>0){
				flag=true;
			}
		}
		
		return flag;
	}

	
}
